{% include "head.twig" %}
{% include "header.twig" %}
{{ cart|raw }}
{% if tovar_in_cart != 0 %}
<div {#id="openModal" class="modalDialog"#}>
<div>
        {#<a href="#" title="Close" onclick="hidemodal()" class="close">X</a>#}
        <div id="modal_tovar_in_cart_table_block">
            <h2>Товары в корзине:</h2>

            <table class="modal_tovar_in_cart_table">
                <tr class="modal_tovar_in_cart_tr">
                    <td class="image_tc" >Изображение товара</td>
                    <td class="name_tc">Название</td>
                    <td class="price_tc">Цена</td>
                    <td class="number_tc">Количество</td>
                    <td class="nomer_tc nomer_tc_top">x</td>
                    <td class="summ_price_tc">На сумму</td></tr>
            </table>
            <div class="modal_tovar_in_cart">
                <table class="modal_tovar_in_cart_table">
                    {% if cartProduct != NULL %}
                    {% for kay, value in  cartProduct %}
                        {% if value['number'] != null  %}
                    <tr>
                        <td class="image_tc"><img class="img_tovar_details" src="/myfile/{{ value['Image'] }}"</td>
                        <td class="name_tc">{{ value['Name'] }}</td>
                        <td class="price_tc">{{ value['Price'] }}</td>
                        <td class="number_tc">
                            <form method="POST" name="tovar_in_cart_{{ value['id'] }}" class="tovar_in_cart"   action="/cart.php">
                            <input type="text" value="{{ value['id'] }}" name = "id_tovar_cart" style="display: none;">
                            <input type="text" class="input_number_tovar_in_cart" size="1"  value="{{ value['number'] }}"
                            onkeypress="javascript: if((event.charCode < 48)||(event.charCode > 57)) return false;"
                            onfocus="javascript:if(this.value=='{{ value['number'] }}')this.value='' "  onblur="javascript:if(this.value=='')this.value='{{ value['number'] }} '" onchange="document.tovar_in_cart_{{ value['id'] }}.submit(); return false;" name="number_tovar_in_cart" >
                            <input type="submit" value="Submit" style="display: none;">
                            </form>
                        </td>
                        <td class="nomer_tc">
                            <form method="POST" name="tovarCart{{ value['id'] }}" class="tovar_in_cart"   action="/cart.php">
                            <input type="text" value="{{ value['id'] }}" name = "id_tovar_cart" style="display: none;">
                            <input type="text" class="input_number_tovar_in_cart" size="1"  value="0" name="number_tovar_in_cart" style="display: none;">
                            <input type="submit" value="x" >
                            </form>
                        </td>
                        <td class="summ_price_tc">{{ value['number'] * value['Price'] }}</td>
                    </tr>
                            {% endif %}
                    {% endfor %}
                    {% endif %}
                </table>
            </div>

            <table class="modal_tovar_in_cart_table">
                <tr><td class="price_summa" colspan=5> Сумма заказа:    </td>

                    <td class="summ_price_tc all_summ_price_tc">{{ tovar_in_price }}</td></tr>

            </table>

            <p class="make_bay_block">

                <input type="button" id="contactbutton" value="Оформить заказ" onclick="show('wind')/*hide('modal_tovar_in_cart_table_block', 'wind')*/" /> <a href="/" class="back_to_bay">Продолжить покупки</a>   <a href="/cart.php?bay=2" id="clean_cart">Очистить корзину</a>
            </p>

        </div>
        {% else %}

        <div {#id="openModal" class="modalDialog"#}>
            <div>
                <a href="#" title="Close" onclick="hidemodal()" class="close">X</a>
                <div id="modal_tovar_in_cart_table_block">
                    <h2>В корзине товаров нет!</h2>

                </div>
        {% endif %}


                <div id="contacts">

                    <div  id="wind">
                        <h4 class="podschet_h4">Оформить заказ</h4>
                        {{ podschetError }}
                        <form name="contactus"  id="contactus" method="post" action="/index.php#openModal">
                            <table class="podschet">

                                <tr>
                                    <td><p>Имя и фамилия</p>
                                    </td>
                                </tr>
                                <tr>
                                    <td ><input name="ClientName"   type="text" value="$ClientName" class="input_box" >
                                    </td></tr>
                                <tr>
                                    <td ><p>Контактный телефон</p>
                                    </td>
                                </tr>
                                <tr>
                                    <td><input maxlength="12"  onkeypress="javascript: if((event.charCode < 48)||(event.charCode > 57)) return false;"
                                               name="phone" value="$phone" type="text" class="input_box" title="" />
                                    </td>
                                </tr>
                                <tr>
                                    <td><p>Электронный адрес</p>
                                    </td>
                                </tr>
                                <tr>
                                    <td><input name="email" type="text" placeholder="name@mail.com" value="$email" class="required email input_box" title="" />
                                    </td>
                                </tr>

                                <tr>
                                    <td ><p>Тип доставки</p>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <select name="delivery" id="delivery">
                                            <option value="Самовывоз">Заберу с магазина</option>
                                            <option value="Курьерская доставка">Доставка домой</option>
                                            <option value="Новая почта">Новая почта</option>

                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td><p>Адрес</p>
                                    </td>
                                </tr>
                                <tr>
                                    <td ><input name="description" type="text" value="$description" class="input_box" title="" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>

                                        <input type="submit" name="zapusk2" id="contactbutton" value="Подать заявку"/>
                                    </td>
                                </tr>
                            </table>

                        </form>
                        <div onclick="hide('wind', 'modal_tovar_in_cart_table_block')"  class="button_back"><p>Назад к списку покупок</p>
                        </div>

                </div>

            </div>
        </div>

    </div>

</div>
    <script>

        function hide(nodeId,  nodeID2)
        {
            var node = document.getElementById(nodeId);
            if (node)
            {
                node.style.display = 'none';
                show(nodeID2);
            }
        }

        function show(nodeId)
        {
            var node = document.getElementById(nodeId);
            if (node)
            {
                node.style.display = 'block';
            }
        }


    </script>
{% include "footer.twig" %}